<?php
require_once '../Gallery.php';

class GalleryTest extends PHPUnit_Framework_TestCase
{
  /**
   * This test should pass with a 200 if we try to create a new subdir
   * in the given galleryfolder from the config file.
   * @covers Gallery::mkdir
   * @group filesys
   */
  public function testMkdirGood()
  {
    $this->assertEquals('200', Gallery::mkdir('summervacation'));
  }

  /**
   * This test should get a 403 in return for that it tries to
   * create a subdir in the rootfolder that is NOT the galleryfolder.
   * @covers Gallery::mkdir
   * @group filesys
   */
  public function testMkdirBad()
  {
    $this->assertEquals('403', Gallery::mkdir('/wintervacation'));
  }

  /**
   * This test should pass with a 200 if we try to rename a subdir of the
   * given galleryfolder from the config file.
   * @covers Gallery::mv
   * @depends testMkdirGood
   * @group filesys
   */
  public function testMvGood()
  {
    $this->assertEquals('200', Gallery::mv('summervacation', 'springvacation'));
  }

  /**
   * This test should get a 403 in return if we try to rename the galleryfolder.
   * @covers Gallery::mv
   * @group filesys
   */
  public function testMvBad()
  {
    $this->assertEquals('403', Gallery::mv('/' . $GALLERYFOLDER, '/BADGALLERY'));
  }

  /**
   * This test should pass with a 200 if we try to delete a subdir of the
   * given galleryfolder.
   * @covers Gallery::rm
   * @depends testMvGood
   * @group filesys
   */
  public function testRmGood()
  {
    $this->assertEquals('200', Gallery::rm('springvacation'));
  }

  /**
   * This test should get a 403 in return if we try to delete the galleryfolder
   * @covers Gallery::rm
   * @depends testMvBad
   * @group filesys
   */
  public function testRmBad()
  {
    $this->assertEquals('403', Gallery::rm('/' . $GALLERYFOLDER));
  }

  /**
   * This test should pass with a 200 and a json-body showing the files and folder list
   * of the given folder
   * @covers Gallery::ls
   * @group filesys
   */
  public function testLsGood()
  {
    $result = Gallery::mkdir('wintervacation');
    $this->assertEquals('200', Gallery::ls('wintervacation'));
    //TODO: json assert test
  }

  /**
   * This test should get a 404 in return if we try to list a not-existing folder.
   * @covers Gallery::ls
   * @group filesys
   */
  public function testLsBad()
  {
    $this->assertEquals('404', Gallery::ls('cheeseburger'));
  }

  /**
   * This test should pass with a 200 if we try to copy a folder.
   * @covers Gallery::cp
   * @depends testLsGood
   * @group filesys
   */
  public function testCpGood()
  {
    $this->assertEquals('200', Gallery::cp('wintervacation'));
  }

  /**
   * This test should get a 404 in return for trying to copy a not-existing folder.
   * @covers Gallery::cp
   * @group filesys
   */
  public function testCpBad()
  {
    $this->assertEquals('404', Gallery::cp('veggieburger'));
  }
}
?>